using Baula.Testing.Common;
using Baula.TextGen.ActiveTemplating.Tokenizer.TokenParsers;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace Baula.TextGen.ActiveTemplating.Tests.Tokenizer.TokenParsers
{
    [TestClass]
    public class LiteralParserTests : TokenParserTestsBase
    {
        [Description("This should be the other way around")]
        [TestMethod]
        public void CanAppend_WithOpeningBraceOnNoString_ReturnsFalse()
        {
            SetInitialContent("There is no string.");
            var actual = _parser.CanAppend('{');
            Assert.IsFalse(actual);
        }

        [Description("This should be the other way around")]
        [TestMethod]
        public void CanAppend_WithOpeningBraceAfterClosedString_ReturnsFalse()
        {
            SetInitialContent("This is before the string. \"This is the string.\". This is after it.");
            var actual = _parser.CanAppend('{');
            Assert.IsFalse(actual);
        }

        //[TestCategory("wip-A.3")]
        [TestMethod]
        public void CanAppend_WithOpeningBraceOnOpenString_ReturnsFalse()
        {
            SetInitialContent("This is before the string. \"This is the unclosed string.");
            var actual = _parser.CanAppend('{');
            Assert.IsFalse(actual);
        }

        [TestMethod]
        public void CreateToken_OnNoString_DoesNotThrowException()
        {
            SetInitialContent("Here is no string expression");
            _parser.CreateToken();
            // Assert.Pass()
        }

        [TestMethod]
        public void CreateToken_AfterClosedString_DoesNotThrowException()
        {
            SetInitialContent("\"This is the string.\" that has been closed before.");
            _parser.CreateToken();
            // Assert.Pass()
        }

        [TestMethod]
        public void CreateToken_OnOpenString_DoesNotThrowException()
        {
            SetInitialContent("some text before the string \"inside the unclosed string");
            _parser.CreateToken();
            // Assert.Passe()
        }

        protected override ITokenParser CreateParser()
        {
            return new LiteralParser();
        }

        protected override void CloseToken(ITokenParser parser)
        {
            // A literal token does not have any suffix.
        }
    }
}